<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
     canvas{
       border: 2px solid blue;
     }
  </style>
</head>
<body>
     <canvas width="500" height="500"></canvas>
     <script>
        var canvas = document.querySelector('canvas')
        var ctx = canvas.getContext('2d')
        //绘制圆
        //开始绘制圆
        ctx.beginPath()
        ctx.arc(100,100,50,0,2*Math.PI,true)
        ctx.fillStyle = 'red'
        ctx.fill()
        ctx.stroke()

        //开始绘制圆形
        ctx.beginPath()
        //画圆:arc(x,y,r,sAngle,eAngle,counterclockwise);
        //x,y:圆心，r：半径，sAngle：起始弧度，eAngle：结束弧度，(0到2PI绘制一个完整的圆)
        //counterclockwise：可选。规定应该逆时针还是顺时针绘图。False = 顺时针，true = 逆时针。
        ctx.arc(300, 200, 100, 0, 1,false)
        //设置填充颜色
        ctx.fillStyle = 'red'
        ctx.fill()
        //完成绘制
        ctx.stroke()
     </script>
</body>
</html>